package com.auxgroup.hr.front.service.personnal.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.dao.domain.PsCPersonalInfoClass;
import com.auxgroup.hr.front.dao.domain.PsCTrainTbl;
import com.auxgroup.hr.front.dao.repository.PsCTrainTblRepository;
import com.auxgroup.hr.front.service.personnal.TrainTblService;

/** 
 * @author wangchangyun
 * @version 创建时间：180523 
 * 教育经历service
 */
@Service("trainTblService")
public class TrainTblServiceImpl implements TrainTblService {
	private static final Logger logger = LoggerFactory.getLogger(TrainTblServiceImpl.class);
	
	@Autowired
	private PsCTrainTblRepository PsCTrainTblRepository;


	@Override
	public PsCTrainTbl getTrainTbl(PsCPersonalInfoClass personalInfo) {
		return PsCTrainTblRepository.findOne(personalInfo);
	}


	@Override
	public PsCTrainTbl save(PsCTrainTbl TrainTbl) {
		return PsCTrainTblRepository.save(TrainTbl);
	}


	@Override
	public Boolean delete(PsCPersonalInfoClass personalInfo) {
		try {
			PsCTrainTblRepository.delete(personalInfo);
		} catch (Exception e) {
			logger.error("delete TrainTbl error: personalInfo={}",personalInfo,e);
			return false;
		}
		return true;
	}
	
	
	@Override
	public List<PsCTrainTbl> getAll(String emplid) {
		PsCTrainTbl TrainTbl = new PsCTrainTbl();
		TrainTbl.setEmplid(emplid);
		return PsCTrainTblRepository.findAll(Example.of(TrainTbl),new Sort(Sort.Direction.DESC,"startDt"));
	}


	
	
	
}
